package com.neusoft.controller.registration;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neusoft.bean.NewPageBean;
import com.neusoft.bean.PageBean;
import com.neusoft.bean.PageRequestDto;
import com.neusoft.service.RegisterService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/registers")
@CrossOrigin
public class RegisterController {

    @Autowired
    private RegisterService
            registerService;

    @GetMapping("/getMaxCaseNumber")
    public String getMaxCaseNumber(){
        return registerService.getMaxCaseNumber();
    }

    @GetMapping("/getDoctorUsedNumber")
    public Integer getDoctorUsedNumber(Integer doctorId){
        Integer number=registerService.getDoctorUsedNumber(doctorId);
        return number;
    }

    @PostMapping("/saveRegister")
    public String saveRegister(@RequestBody Map<String,Object> register){
        return registerService.saveRegister(register);
    }

    @GetMapping("/getFinishPatientCount")
    public Integer getFinishPatientCount(Integer employeeId){
        return registerService.getFinishPatientCount(employeeId);
    }
    @GetMapping("/getWaitPatientCount")
    public Integer getWaitPatientCount(Integer employeeId){
        return registerService.getWaitPatientCount(employeeId);
    }


    @GetMapping("/getWaitPatient")
    public PageBean getWaitPatient(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "5") Integer pageSize,
            @RequestParam Integer employeeId,
            String caseNumber,
            String realName){
        return registerService.getWaitPatient(page,pageSize,employeeId,caseNumber,realName);

    }
    @GetMapping("/getAllPatient")
    public PageBean getAllPatient(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "5") Integer pageSize,
            String caseNumber,
            String realName){
        return registerService.getAllPatient(page,pageSize,caseNumber,realName);

    }
    @PutMapping("/changeVisitState")
    public String changeVisitState(Integer caseNumber){
        registerService.changeVisitState(caseNumber);
        return null;
    }
    @PostMapping("/getWaitCheckPatient")
    public NewPageBean getWaitCheckPatient(@RequestBody PageRequestDto pageRequestDto) {
        return registerService.getWaitCheckPatient(pageRequestDto);
    }

    //根据患者姓名和病历号查询信息
    @GetMapping("/searchPatientInformation")
    public List<Map<String, Object>> searchPatientInformation(String caseNumber, String realName){
        List<Map<String,Object>> list=registerService.searchPatientInformation(caseNumber,realName);
        return list;
    }
    @PostMapping("/getWaitInspectionPatient")
    public NewPageBean getWaitInpectionPatient(@RequestBody PageRequestDto pageRequestDto) {
        return registerService.getWaitInpectionPatient(pageRequestDto);
    }
    @PostMapping("/getWaitDisposalPatient")
    public NewPageBean getWaitDisposalPatient(@RequestBody PageRequestDto pageRequestDto) {
        return registerService.getWaitDisposalPatient(pageRequestDto);
    }
    @GetMapping("/searchDisPatient")
    public PageBean searchPatient(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize,
            String caseNumber, String realName){
        return registerService.searchDisPatient(page,pageSize,caseNumber,realName);

    }
    //分页查询患者信息
    @GetMapping("/checkPatient")
    public PageBean checkPatient(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "5") Integer pageSize,
            String caseNumber,
            String realName){
        return registerService.checkPatient(page,pageSize,caseNumber,realName);
    }
    //名字与上面相同，改为searchPatient2
    @GetMapping("/searchPatient")
    public PageBean searchPatient2(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "5") Integer pageSize,
            String caseNumber, String realName){
        return registerService.searchPatient(page,pageSize,caseNumber,realName);

    }


    //搜索功能y
    @GetMapping("/getWaitCheck")

    public List<Map<String,Object>> getWaitCheck(String realName, String caseNumber){
        return registerService.getWaitCheck(realName,caseNumber);

    }

}
